// JavaScript Document

$(document).ready(function() {	
	$('#example').dataTable( {
		//显示
		/*分页*/ "bPaginate": true,
		/*筛选查询*/ "bFilter": true,
		/*排序*/ "bSort": true,
		/*记录页数信息*/ "bInfo": false,
		/*自动行宽*/ "bAutoWidth": true, 
		/*分页记录长度*/ "bLengthChange": false,
		/*总体样式*/ "bJQueryUI": true,
		
		//样式和个性化
		/*分页条样式*/ "sPaginationType": "full_numbers",
		/*保存操作设定*/ "bStateSave": true,
		
		/*默认排序*/ "aaSorting": [[ 4, "desc" ]], //第四列, 排序方式
		
		//滚动条 X
		"sScrollX": "100%", //外部大小
		"sScrollXInner": "100%", //内部记录宽度大小
		"bScrollCollapse": false, //功能未知
		//滚动条 Y		
		"sScrollY": "200px",
		"bScrollInfinite": true,
		"bScrollCollapse": true,
		
		/*列功能设定*/ 
		"aoColumns": [ 
			/* Engine */   null,
			/* Browser */  null,
			/* Platform */ { 
							"sClass": "center",	/*左中右对齐*/
							"bSortable": false,	/*是否可被排序*/
							"bSearchable": false,	/*不可查询,不可见*/ 
							"bVisible":    false 	/*可查询，不可见*/
							}, 
			/* Version */  { "bVisible":    false },  
			/* Grade */    null
		],
		
		//添加自定义功能条
		"sDom": '<"toolbar">frtip',
		
		//自定义UI文字
		"oLanguage": {"sUrl": "语言文字设定.txt"},
			  
	  	//服务器返回数据
		"bProcessing": true,
		"bServerSide": true,
		"sAjaxSource": "返回数据的php页.php",
		"aoColumns": [ //自定义排序顺序
			{ "sName": "engine" },
			{ "sName": "browser" },
			{ "sName": "platform" },
			{ "sName": "version" },
			{ "sName": "grade" }
		]
		
		
		});

		//添加自定义功能条
		$("div.toolbar").html('Custom tool bar! Text/images etc.');
} );


UI文字.txt
{
	"sProcessing": "Bitte warten...",
	"sLengthMenu": "_MENU_ Eintr盲ge anzeigen",
	"sZeroRecords": "Keine Eintr盲ge vorhanden.",
	"sInfo": "_START_ bis _END_ von _TOTAL_ Eintr盲gen",
	"sInfoEmpty": "0 bis 0 von 0 Eintr盲gen",
	"sInfoFiltered": "(gefiltert von _MAX_  Eintr盲gen)",
	"sInfoPostFix": "",
	"sSearch": "Suchen",
	"sUrl": "",
	"oPaginate": {
		"sFirst":    "Erster",
		"sPrevious": "Zur眉ck",
		"sNext":     "N盲chster",
		"sLast":     "Letzter"
	}
}

php的json返回格式
{"sEcho": 0, 
	"iTotalRecords": 57, 
	"iTotalDisplayRecords": 57, 
	"sColumns": "platform,engine,browser,grade,version",
	"aaData": [ 
		["Win 95+","Trident","Internet Explorer 4.0","X","4"],["Win 95+","Trident","Internet Explorer 5.0","C","5"],["Win 95+","Trident","Internet Explorer 5.5","A","5.5"],["Win 98+","Trident","Internet Explorer 6","A","6"],["Win XP SP2+","Trident","Internet Explorer 7","A","7"]
	] 
}


显示记录详细信息
var oTable;

/* Formating function for row details */
function fnFormatDetails ( nTr )
{
	var aData = oTable.fnGetData( nTr );
	var sOut = '<table cellpadding="5" cellspacing="0" border="0" style="padding-left:50px;">';
	sOut += '<tr><td>Rendering engine:</td><td>'+aData[2]+' '+aData[5]+'</td></tr>';
	sOut += '<tr><td>Link to source:</td><td>Could provide a link here</td></tr>';
	sOut += '<tr><td>Extra info:</td><td>And any further details here (images etc)</td></tr>';
	sOut += '</table>';
	
	return sOut;
}

$(document).ready(function() {
	oTable = $('#example').dataTable( {
		"bProcessing": true,
		"bServerSide": true,
		"sAjaxSource": "../examples_support/server_processing_details_col.php",
		"aoColumns": [
			{ "sClass": "center", "bSortable": false },
			null,
			null,
			null,
			{ "sClass": "center" },
			{ "sClass": "center" }
		],
		"aaSorting": [[1, 'asc']]
	} );
	
	$('#example tbody td img').live( 'click', function () {
		var nTr = this.parentNode.parentNode;
		if ( this.src.match('details_close') )
		{
			/* This row is already open - close it */
			this.src = "../examples_support/details_open.png";
			oTable.fnClose( nTr );
		}
		else
		{
			/* Open this row */
			this.src = "../examples_support/details_close.png";
			oTable.fnOpen( nTr, fnFormatDetails(nTr), 'details' );
		}
	} );
} );